package com.witframework.web.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.witframework.core.resource.SpringResourceBundle;


public class I18nBundleTag extends TagSupport{
	private String baseName;
	@Override
	public int doStartTag() throws JspException {		
		SpringResourceBundle srb=new SpringResourceBundle();	
		srb.init(pageContext.getRequest().getLocale());
		JspWriter writer = pageContext.getOut();
		try {			
			writer.println(srb.getMessage(baseName));
		} catch (IOException e) {
			throw new JspException("Print/Flush in LoadingTag tag error:" + e);
		}
		return (EVAL_BODY_INCLUDE);
	}
	public String getBaseName() {
		return baseName;
	}
	public void setBaseName(String baseName) {
		this.baseName = baseName;
	}	
}
